﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.ModFlow.Domain.DomainLayer
{

    /// <summary>
    /// 
    /// 用于存储网格生成时，的配置信息
    /// </summary>
    [Serializable]
    public class GridConfig : ICloneable
    {

        public GridConfig()
        {

            this.OrgX = 0;
            this.OrgY = 0;
            this.OrgZ = 0;

            this.Rotate = 0;


            this.CellX = 10;

            this.CellY = 10;

            this.CellZ = 1;

            this.LengthX = 100;

            this.LengthY = 100;

            this.LengthZ = 10;

        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="isRefinedPointMode"></param>
        /// <param name="nrows"></param>
        /// <param name="ncols"></param>
        /// <param name="nlayers"></param>
        /// <param name="xlength"></param>
        /// <param name="ylength"></param>
        /// <param name="zlength"></param>
        /// <param name="orgX"></param>
        /// <param name="orgY"></param>
        /// <param name="orgZ"></param>
        /// <param name="rotate">旋转角度</param>
        public GridConfig(bool isRefinedPointMode, int nrows, int ncols, int nlayers, double xlength, double ylength, double zlength, double orgX, double orgY, double orgZ, double rotate)
        {

            this.IsRefinedPointMode = isRefinedPointMode;


            this._lengthX = xlength;
            this._lengthY = ylength;
            this._lengthZ = zlength;
            this._orgX = orgX;
            this._orgY = orgY;
            this._orgZ = orgZ;
            this._rotate = rotate;


            this._cellY = nrows;
            this._cellX = ncols;
            this._cellZ = nlayers;




        }


        public GridConfig(bool isRefinedPointMode,
                        double xlength, double ylength, double zlength, double orgX, double orgY, double orgZ, double rotate,
                        double BiasX, double BaseCellSizeX, double LimitCellSizeX, int ncols, bool IsUseBLX,
                        double BiasY, double BaseCellSizeY, double LimitCellSizeY, int nrows, bool IsUseBLY,
                        double BiasZ, double BaseCellSizeZ, double LimitCellSizeZ, int nlayers, bool IsUseBLZ)
        {

            this.IsRefinedPointMode = isRefinedPointMode;


            this._lengthX = xlength;
            this._lengthY = ylength;
            this._lengthZ = zlength;
            this._orgX = orgX;
            this._orgY = orgY;
            this._orgZ = orgZ;
            this._rotate = rotate;

            this._biasX = BiasX;
            this._baseCellSizeX = BaseCellSizeX;
            this.LimitCellSizeX = LimitCellSizeX;
            this.IsUseBLX = IsUseBLX;
            this._cellX = ncols;




            this._biasY = BiasY;
            this.BaseCellSizeY = BaseCellSizeY;
            this.LimitCellSizeY = LimitCellSizeY;
            this.IsUseBLY = IsUseBLY;
            this._cellY = nrows;

            this.BiasZ = BiasZ;
            this.BaseCellSizeZ = BaseCellSizeZ;
            this.LimitCellSizeZ = LimitCellSizeZ;
            this.IsUseBLZ = IsUseBLZ;
            this._cellZ = nlayers;


        
        
        }




        /// <summary>
        /// 对应于创建 RefinePoint 的网格
        /// </summary>
        /// <param name="isRefinedPointMode"></param>
        /// <param name="xlength"></param>
        /// <param name="ylength"></param>
        /// <param name="zlength"></param>
        /// <param name="orgX"></param>
        /// <param name="orgY"></param>
        /// <param name="orgZ"></param>
        /// <param name="rotate"></param>
        /// <param name="zBias"></param>
        /// <param name="zBaseCellSize"></param>
        /// <param name="zMaxCellSize"></param>
        /// <param name="zNumCell"></param>
        /// <param name="zUseBaseLimit"></param>
        /// <param name="refinePoint"></param>
        public GridConfig(bool isRefinedPointMode,
            double xlength, double ylength, double zlength, double orgX, double orgY, double orgZ, double rotate,
            double zBias, double zBaseCellSize, double zMaxCellSize, int zNumCell, bool zUseBaseLimit,
            List<HAMath. RefinePoint> refinePoint)
        {

            this.IsRefinedPointMode = isRefinedPointMode;


            this._lengthX = xlength;
            this._lengthY = ylength;
            this._lengthZ = zlength;
            this._orgX = orgX;
            this._orgY = orgY;
            this._orgZ = orgZ;
            this._rotate = rotate;



            this.BiasZ = zBias;
            this.BaseCellSizeZ = zBaseCellSize;
            this.LimitCellSizeZ = zMaxCellSize;
            this.IsUseBLZ = zUseBaseLimit;
            this._cellZ = zNumCell;

            if (this.refinePointList ==null )
            {
                refinePointList = new List<HAMath.RefinePoint>();

            }
            for (int i = 0; i < refinePoint.Count ; i++)
            {
                HAMath.RefinePoint point = new HAMath.RefinePoint();

                point.RefinePointCoor.XCoordinate = refinePoint[i].RefinePointCoor.XCoordinate;
                point.RefinePointCoor.YCoordinate = refinePoint[i].RefinePointCoor.YCoordinate;
                point.RefinePointCoor.ZCoordinate = refinePoint[i].RefinePointCoor.ZCoordinate;

                point.Bisa = refinePoint[i].Bisa;
                point.BaseSize = refinePoint[i].BaseSize;
                point.MaxSize = refinePoint[i].MaxSize;

                this.refinePointList.Add(point );

            }


        
        }


        List<HAMath.RefinePoint> refinePointList = new List<HAMath.RefinePoint>();
        /// <summary>
        /// 存储 RefinePoint 的点信息
        /// </summary>
        public List<HAMath.RefinePoint> RefinePointList
        {
            get { return refinePointList; }
            set { refinePointList = value; }
        }




        bool _isRefinedPointMode = false;

        public bool IsRefinedPointMode
        {
            get { return _isRefinedPointMode; }
            set { _isRefinedPointMode = value; }
        }

        #region



        double _orgX;

        public double OrgX
        {
            get { return _orgX; }
            set { _orgX = value; }
        }

        double _orgY;

        public double OrgY
        {
            get { return _orgY; }
            set { _orgY = value; }
        }

        double _orgZ;

        public double OrgZ
        {
            get { return _orgZ; }
            set { _orgZ = value; }
        }

        double _rotate;

        public double Rotate
        {
            get { return _rotate; }
            set { _rotate = value; }
        }

        double _lengthX;

        public double LengthX
        {
            get { return _lengthX; }
            set { _lengthX = value; }
        }

        double _lengthY;

        public double LengthY
        {
            get { return _lengthY; }
            set { _lengthY = value; }
        }

        double _lengthZ;

        public double LengthZ
        {
            get { return _lengthZ; }
            set { _lengthZ = value; }
        }

        #endregion



        int _cellX;

        public int CellX
        {
            get { return _cellX; }
            set { _cellX = value; }
        }

        int _cellY;

        public int CellY
        {
            get { return _cellY; }
            set { _cellY = value; }
        }

        int _cellZ;

        public int CellZ
        {
            get { return _cellZ; }
            set { _cellZ = value; }
        }





        double _biasX = 1.0;

        public double BiasX
        {
            get { return _biasX; }
            set { _biasX = value; }
        }
        double _biasY = 1.0;

        public double BiasY
        {
            get { return _biasY; }
            set { _biasY = value; }
        }

        double _biasZ = 1.0;

        public double BiasZ
        {
            get { return _biasZ; }
            set { _biasZ = value; }
        }





        bool _isUseBLX = false;

        public bool IsUseBLX
        {
            get { return _isUseBLX; }
            set { _isUseBLX = value; }
        }
        bool _isUseBLY = false;

        public bool IsUseBLY
        {
            get { return _isUseBLY; }
            set { _isUseBLY = value; }
        }
        bool _isUseBLZ = false;

        public bool IsUseBLZ
        {
            get { return _isUseBLZ; }
            set { _isUseBLZ = value; }
        }


        double _baseCellSizeX = 10;

        public double BaseCellSizeX
        {
            get { return _baseCellSizeX; }
            set { _baseCellSizeX = value; }
        }
        double _baseCellSizeY = 10;

        public double BaseCellSizeY
        {
            get { return _baseCellSizeY; }
            set { _baseCellSizeY = value; }
        }
        double _baseCellSizeZ = 4;

        public double BaseCellSizeZ
        {
            get { return _baseCellSizeZ; }
            set { _baseCellSizeZ = value; }
        }


        double _limitCellSizeX = 50;

        public double LimitCellSizeX
        {
            get { return _limitCellSizeX; }
            set { _limitCellSizeX = value; }
        }
        double _limitCellSizeY = 50;

        public double LimitCellSizeY
        {
            get { return _limitCellSizeY; }
            set { _limitCellSizeY = value; }
        }
        double _limitCellSizeZ = 20;

        public double LimitCellSizeZ
        {
            get { return _limitCellSizeZ; }
            set { _limitCellSizeZ = value; }
        }





        #region ICloneable 成员

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        #endregion
    }
}
